package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/repair")
public class RepairController {
    @Autowired
    RepairService repairService;


    @GetMapping("select")
    public JsonResult selectRepair(RepairQuery repairQuery){
        log.debug("查询维修单，参数{}", repairQuery);
        List<RepairVO> list=repairService.select(repairQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult saveRepair(RepairSaveParam repairSaveParam){
        log.debug("保存维修单，参数{}", repairSaveParam);
        repairService.save(repairSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteRepair(@PathVariable Long id){
        log.debug("删除维修单，参数{}",id);
        repairService.deleteRepair(id);
        return JsonResult.ok();
    }


}
